package com.cl.unipay4j.wx.pay;

import com.cl.unipay4j.core.IPayConfig;
import com.cl.unipay4j.core.pay.PayModel;
import com.cl.unipay4j.core.Result;
import lombok.extern.slf4j.Slf4j;

import java.util.HashMap;
import java.util.Map;

/**
 * Native支付
 * 用户扫描商户展示在各种场景的二维码进行支付
 *
 * @Author Small
 * @Date 2019/11/28 9:52
 * @Version 1.0
 **/
@Slf4j
public class WxPayNative extends WxPay {

    public WxPayNative() {
        super();
    }

    public WxPayNative(IPayConfig payConfig) {
        super(payConfig);
    }

    /**
     * 二维码支付
     *
     * @Author Small
     * @param model
     * @Date 2019/11/29 10:02
     * @return com.weixing.mall.pay.PayResult
     */
    @Override
    public Result pay(PayModel model) {
        return doPay(model, WxTradeTypeEnum.NATIVE);
    }


    /**
     * 是否需要openId参数
     * @return
     */
    @Override
    public boolean needOpenId() {
        return false;
    }


    @Override
    public Result doTradeSuccess(Map<String, String> r) {
        Map<String, Object> map = new HashMap<>(2);
        map.put("code_url", r.get("code_url"));
        return Result.tradeSuccess(map);
    }
}
